package com.example.cardiacmonitor.patient

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PatientInfoScreen(navController: NavHostController) {
    // 预定义的患者信息
    val patientInfo = mapOf(
        "姓名" to "张三",
        "年龄" to "30",
        "性别" to "男",
        "患者ID" to "PAT12345",
        "联系电话" to "13800138000",
        "病史" to "高血压，糖尿病",
        "负责医生" to "王医生"
    )

    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text("患者信息管理") },
                navigationIcon = {
                    IconButton(onClick = { navController.popBackStack() }) {
                        Icon(Icons.Filled.ArrowBack, contentDescription = "返回")
                    }
                }
            )
        }
    ) { innerPadding ->
        Column(
            modifier = Modifier
                .padding(innerPadding)
                .padding(all = 16.dp)
                .verticalScroll(rememberScrollState())
        ) {
            patientInfo.forEach { (label, value) ->
                OutlinedTextField(
                    value = value,
                    onValueChange = {}, // 不允许用户输入
                    label = { Text(label) },
                    modifier = Modifier.fillMaxWidth(),
                    readOnly = true // 设置为只读
                )
                Spacer(modifier = Modifier.height(16.dp))
            }

            // 保存按钮（如果需要）
            Button(
                onClick = { /* 保存逻辑 */ },
                modifier = Modifier.fillMaxWidth()
            ) {
                Text("保存信息")
            }
        }
    }
}